import React, { Component } from "react";
import "../css/header.css";
import eventEmitter from "../events";

class Headers extends Component {
  constructor(props) {
    super(props);
    this.state = {};
    this.add = (e) => {
      if (e.keyCode == 13) {
        let value = e.target.value;
        let obj = { value: value, flag: 0 };
        eventEmitter.emit("submissions", obj);
      }
    };
  }

  render() {
    return (
      <div className="content_head">
        <div className="headers">
          <h1>ToDoList</h1>
          <input type="text" placeholder="添加ToDo" onKeyDown={this.add} />
        </div>
      </div>
    );
  }
}

export default Headers;
